package com.alan.libapi.api.Impl;

import com.alan.libapi.model.business.TcpJsonRequest;
import com.alan.libapi.model.business.SharedWifiInfo;
import com.alan.libapi.model.business.TcpDeleteDeviceUser;
import com.alan.libapi.model.business.TcpModifyDeviceWifi;
import com.alan.libapi.model.business.TcpRequestBaseParam;
import com.alan.libapi.model.business.TcpSendWifiListParam;
import com.alan.libapi.model.persistent.CmdIds;
import com.alan.libapi.model.persistent.CmdNames;
import com.alibaba.fastjson.JSON;

import java.util.List;

/**
 * @className: JsonRequestHelper
 * @describtion: JsonRequestHelper
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/4/28 16:21
 */
public class JsonRequestHelper {

    /**
     * 获取 发送设备拥有者详细信息命令 的Json字符串
     * @param deviceMasterId
     * @return
     */
    public static String getJsonStrOfSendMasterInfo(int deviceMasterId){
        TcpJsonRequest<TcpRequestBaseParam> jsonRequest = new TcpJsonRequest<>(
                CmdIds.TCPA.CMD_01_SEND_MASTER_INFO,
                CmdNames.TCPA.CMD_01_SEND_MASTER_INFO,
                new TcpRequestBaseParam(deviceMasterId)
        );
       return JSON.toJSONString(jsonRequest);
    }

    /**
     * 获取 发送设备附近周围分享的热点信息命令 的Json字符串
     * @param deviceMasterId
     * @param wifiInfoList
     * @return
     */
    public static String getJsonStrOfSendWifiInfo(int deviceMasterId, List<SharedWifiInfo> wifiInfoList){
        TcpJsonRequest<TcpSendWifiListParam> jsonRequest = new TcpJsonRequest<>(
                CmdIds.TCPA.CMD_02_SEND_WIFI_INFO,
                CmdNames.TCPA.CMD_02_SEND_WIFI_INFO,
                new TcpSendWifiListParam(deviceMasterId, wifiInfoList)
        );
        return JSON.toJSONString(jsonRequest);
    }

    /**
     * 获取 修改WL设备Wifi的SSID或者密码信息命令 的Json字符串
     * @param deviceMasterId
     * @param SSID
     * @param password
     * @return
     */
    public static String getJsonStrOfModifyDeviceWifi(int deviceMasterId, String SSID, String password){
        TcpJsonRequest<TcpModifyDeviceWifi> jsonRequest = new TcpJsonRequest<>(
                CmdIds.TCPA.CMD_03_MODIFY_DEVICE_WIFI,
                CmdNames.TCPA.CMD_03_MODIFY_DEVICE_WIFI,
                new TcpModifyDeviceWifi(deviceMasterId, SSID, password)
        );
        return JSON.toJSONString(jsonRequest);
    }

    /**
     * 获取 获取WL设备所有已连接上的所有设备信息命令 的Json字符串
     * @param deviceMasterId
     * @return
     */
    public static String getJsonStrOfGetDeviceUserList(int deviceMasterId){
        TcpJsonRequest<TcpRequestBaseParam> jsonRequest = new TcpJsonRequest<>(
                CmdIds.TCPA.CMD_04_GET_DEVICE_USER_LIST,
                CmdNames.TCPA.CMD_04_GET_DEVICE_USER_LIST,
                new TcpRequestBaseParam(deviceMasterId)
        );
        return JSON.toJSONString(jsonRequest);
    }

    /**
     * 获取 删除WL设备指定的已连接上的用户设备命令 的Json字符串
     * @param deviceMasterId
     * @param userMac
     * @return
     */
    public static String getJsonStrOfDeleteDeviceUser(int deviceMasterId, String userMac){
        TcpJsonRequest<TcpDeleteDeviceUser> jsonRequest = new TcpJsonRequest<>(
                CmdIds.TCPA.CMD_05_DELETE_DEVICE_USER,
                CmdNames.TCPA.CMD_05_DELETE_DEVICE_USER,
                new TcpDeleteDeviceUser(deviceMasterId, userMac)
        );
        return JSON.toJSONString(jsonRequest);
    }
}
